/**
 *******************************************************************************
 * @FileName  : watchdog.c
 * @Author    : GaoQiu
 * @CreateDate: 2020-05-18
 * @Copyright : Copyright(C) GaoQiu
 *              All Rights Reserved.
 *******************************************************************************
 */
#include "watchdog.h"
#include "platform/platform.h"


void WDG_SetUp(void)
{
	/* GPIO config. */
	GPIO_InitType_t GPIO_InitStrut;
	GPIO_InitStrut.GPIO_Pin  = GPIO_Pin_2;
	GPIO_InitStrut.GPIO_Mode = GPIO_Mode_Out;
	GPIO_InitStrut.GPIO_Pull = GPIO_Pull_Floating;
	GPIO_Init(GPIOD, &GPIO_InitStrut);

	WDG_Init(500, 48);
	WDG_Cmd(ENABLE);
	WDG_FeedDog();
}

void WDG_Loop(void)
{
	/* Watchdog Timeout */
	delay_ms(600);

	WDG_FeedDog();

	GPIO_ToggleBits(GPIOD, GPIO_Pin_2);
}

